<%@ page language="java" pageEncoding="utf-8"%>
<%@page import="org.jbpm.taskmgmt.exe.TaskInstance"%>
<%@ include file="include.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>login page</title>
	</head>
	<body>
		<h1>
			以下任务需要你处理：
		</h1>
		<br>
		<table width="100%" border="1" cellpadding="0" cellspacing="0">
			<tr bgcolor="#FDFDD0">
				<td>
					任务名称
				</td>
				<td>
					创建时间
				</td>
				<td>
					流程图
				</td>
				<td>
					操作
				</td>
			</tr>
			<%
				JbpmContext jbpmContext = JbpmConfiguration.getInstance()
						.createJbpmContext();
				try {
					String currentperson = session.getAttribute("user").toString();
					List taskList = jbpmContext.getTaskList(currentperson);
					if (taskList != null && taskList.size() > 0) {
						SimpleDateFormat sd = new SimpleDateFormat(
								"yyyy-MM-dd HH:mm:ss");
						for (Iterator iter = taskList.iterator(); iter.hasNext();) {
							out.println("<tr>");
							TaskInstance ti = (TaskInstance) iter.next();
							out.println("<td>" + ti.getName() + "</td>");
							out.println("<td>" + sd.format(ti.getCreate())
									+ "</td>");
							out.println("<td><a href=\"#\">查看流程进度</a></td>");

							String description = ti.getDescription();
							String url = request.getContextPath() + "/toManager.do";
							if (description.equals("manager.approve")
									|| description.equals("sm.approve")) {
								url = request.getContextPath() + "/toManager.do";
							}
							url += "?taskId=" + ti.getId();
							out.println("<td><a href=\"" + url
									+ "\">处理该任务</a></td>");
							out.println("</tr>");
						}
					} else {
			%>
			<tr>
				<td colspan="4">
					你没有任务要处理！！
				</td>
			</tr>
			<%
				}
				} finally {
					jbpmContext.close();
				}
			%>
		</table>
	</body>
</html>